﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Zws.Frameworker.Module;

namespace Zws.MongoDb
{
    public class ZwsMongoDbModule : ModuleMark
    {
        public void OnBuilderExec(WebApplicationBuilder builder)
        {
            builder.Services.AddSingleton(typeof(MongoDbClientFacade), new MongoDbClientFacade(new MongoDbConfig
            {
                Ip = builder.Configuration["MongoDb:Ip"],
                Pwd = builder.Configuration["MongoDb:Pwd"],
                Port = builder.Configuration["MongoDb:Port"],
                AuthSource = builder.Configuration["MongoDb:AuthSource"],
                UserName = builder.Configuration["MongoDb:UserName"],
                AuthMechanism = builder.Configuration["MongoDb:AuthMechanism"],
            }));
        }
    }
}
